/**
 * axios封装
 * 
*/

import { Message } from "element-ui";
import axios from "axios";
import router from "@/router/router";

// 创建axios配置，添加全局配置
const service = axios.create({
    baseURL: process.env.VUE_APP_BASE_API,
    timeout: 8000
})

// 请求拦截
service.interceptors.request.use((req)=>{
    const headers = req.headers;
    // token
    if(!headers.Authorization){
        headers.Authorization = 'bearer likai'
    }
    return req;
})

// 响应拦截
service.interceptors.response.use((res)=>{
    const {code, data, message} = res.data
    // 403 无权限（认证信息为空）
    if (code === 403){
        
    }
})